package com.nameless.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.nameless.util.UserFilterIdCardUtil;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

import java.io.Serializable;
import java.util.Date;

/**
 * <p>
 * 
 * </p>
 *
 * @author chh
 * @since 2023-02-26
 */
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@TableName("tb_common_customer")
@ApiModel(value="CommonCustomer对象", description="")
public class CommonCustomer implements Serializable {

    private static final long serialVersionUID = 1L;

    @TableId(value = "id", type = IdType.AUTO)
    private Integer id;

    @ApiModelProperty(value = "会员ID")
    private Integer memberId;

    @ApiModelProperty(value = "名字")
    private String cusName;

    @ApiModelProperty(value = "手机")
    private String phoneNum;

    @ApiModelProperty(value = "证件类型(身份证)")
    private String credentialsType;

    @ApiModelProperty(value = "身份证号")
    private String idNumber;

    @ApiModelProperty(value = "领取驾照时间（年月）")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date getlicenseTime;

    @TableField(exist = false)
    private Integer age;
    @TableField(exist = false)
    private String birthday;

    public Integer getAge() {
        return (idNumber == null?null: UserFilterIdCardUtil.getAgeByIdCard(idNumber));
    }

    public void setAge(Integer age) {
        this.age = age;
    }

    public String getBirthday() {
        return idNumber == null?null: UserFilterIdCardUtil.getBirthdayByIdCard(idNumber);
    }

    public void setBirthday(String birthday) {
        this.birthday = birthday;
    }
}
